package com.itheima.controller;

import com.itheima.Emtity.Orders;
import com.itheima.common.R;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 用户下单
     * 订单确认有 购物车 用户ID 备注.
     * params 用户地址id    支付方式   备注
     *
     * @return
     */
    @PostMapping("submit")
    public R<String> submit(@RequestBody Orders orders) {
        log.info(String.valueOf(orders));
        orderService.submit(orders);
        return R.success("下单成功");
    }
}
